﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Services;
using DevExpress.XtraScheduler.Commands;
using DevExpress.Utils.Menu;
using DevExpress.XtraScheduler.Drawing;
using DevExpress.XtraScheduler.Printing;
using DevExpress.XtraScheduler.Reporting;
using DevExpress.XtraReports.UI;

namespace QLTV.Forms.KeHoach
{
    public partial class frmLongPlanVessel : BaseForm
    {

        public frmLongPlanVessel()
        {
            // handle vertical scroll


            InitializeComponent();
            Database.dsPermission dspermision1 = new Database.dsPermission();
            this.Datasource = dspermision1;
            schedulerControl1.ActiveView.ViewInfo.VisibleResources.CollectionChanged += schedulerControl1_CollectionChanged;
            schedulerControl2.ActiveView.ViewInfo.VisibleResources.CollectionChanged += schedulerControl2_CollectionChanged;
            this.schedulerStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("VesselID", "nVesselId"));
            this.schedulerStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("CrewID", "nCrewId"));
            this.schedulerStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("PlanID", "PlanID"));
            this.schedulerStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("nContract", "nContract"));
            this.schedulerStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("ShortName", "ShortName"));
            this.schedulerStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("GroupName", "GroupName"));


        }
        void schedulerControl1_CollectionChanged(object sender, DevExpress.Utils.CollectionChangedEventArgs<Resource> e)
        {
            try
            {
                schedulerControl2.ActiveView.ViewInfo.VisibleResources.CollectionChanged -= schedulerControl2_CollectionChanged;
                schedulerControl2.ActiveView.FirstVisibleResourceIndex = schedulerControl1.ActiveView.FirstVisibleResourceIndex;
                schedulerControl2.ActiveView.ResourcesPerPage = schedulerControl1.ActiveView.ResourcesPerPage;
                schedulerControl2.ActiveView.ViewInfo.VisibleResources.CollectionChanged += schedulerControl2_CollectionChanged;
            }
            catch (Exception ex) { }

        }
        void schedulerControl2_CollectionChanged(object sender, DevExpress.Utils.CollectionChangedEventArgs<Resource> e)
        {
            try
            {
                schedulerControl1.ActiveView.ViewInfo.VisibleResources.CollectionChanged -= schedulerControl1_CollectionChanged;
                schedulerControl1.ActiveView.FirstVisibleResourceIndex = schedulerControl2.ActiveView.FirstVisibleResourceIndex;
                schedulerControl1.ActiveView.ResourcesPerPage = schedulerControl2.ActiveView.ResourcesPerPage;
                schedulerControl1.ActiveView.ViewInfo.VisibleResources.CollectionChanged += schedulerControl1_CollectionChanged;
            }
            catch (Exception ex) { }
        }
        private List<string> GetColors()
        {
            //create a generic list of strings
            List<string> colors = new List<string>();
            //get the color names from the Known color enum
            string[] colorNames = Enum.GetNames(typeof(KnownColor));
            //iterate thru each string in the colorNames array
            foreach (string colorName in colorNames)
            {
                //cast the colorName into a KnownColor
                KnownColor knownColor = (KnownColor)Enum.Parse(typeof(KnownColor), colorName);
                //check if the knownColor variable is a System color
                if (knownColor > KnownColor.Transparent && knownColor != KnownColor.Black)
                {
                    //add it to our list
                    colors.Add(colorName);
                }
            }
            //return the color list
            return colors;
        }
        private void addLabel(int number)
        {
            Database.dsLongPlanTableAdapters.tblColorTableAdapter tadColor = new Database.dsLongPlanTableAdapters.tblColorTableAdapter();
            tadColor.Fill(dsLongPlan.tblColor);
            Random random = new Random();
            schedulerStorage2.Appointments.Labels.Clear();
            schedulerStorage1.Appointments.Labels.Clear();
            for (int i = 0; i < dsLongPlan.tblColor.Rows.Count; i++)
            {
                string color = dsLongPlan.tblColor.Rows[i]["Color"].ToString().Trim();
                AppointmentLabel lbl = new AppointmentLabel(Color.FromName(color), color, color);
                schedulerStorage2.Appointments.Labels.Add(lbl);
                schedulerStorage1.Appointments.Labels.Add(lbl);
            }
        }
        public int PlanID { get; set; }
        public bool isNew { get; set; }
        public bool isView { get; set; }
        void checkPersion()
        {
            cmdSave.Enabled = MyPermission.Sua;
            cmdXoa.Enabled = MyPermission.Sua;
            cmdXuat.Enabled = MyPermission.Xuat;

        }
        private void frmLongPlanVessel_Load(object sender, EventArgs e)
        {
            checkPersion();
            if (isView)
            {
                cmdDong.Enabled = false;
                cmdSave.Enabled = false;
                cmdXoa.Enabled = false;


            }
            loadData();
        }
        public void loadData()
        {
            tblVesselTableAdapter.Fill(dsLongPlan.tblVessel);
            this.tblRankTableAdapter.Fill(this.dsLongPlan.tblRank);
            this.tblFlagTableAdapter.Fill(this.dsVessel.tblFlag);
            this.tblVesselGroupTableAdapter.Fill(this.dsVessel.tblVesselGroup);
            //gán màu ngẫu nhiên cho từng tàu
            addLabel(dsLongPlan.tblVessel.Rows.Count);

            if (isNew)
            {
                tblKeHoachBindingSource.AddNew();
                radioGroup1.SelectedIndex = 0;
                datePlanCreated.EditValue = DateTime.Now.Date;
                txtNguoiLap.EditValue = Program.EmployeeName;
                từDateEdit.EditValue = new DateTime(DateTime.Now.Year, 1, 1);
                đếnDateEdit.EditValue = new DateTime(DateTime.Now.Year + 1, 12, 30);
                this.tblCurrentOnBoardTableAdapter.Fill(this.dsAssignment.tblCurrentOnBoard);
            }
            else
            {

                this.tblKeHoachTableAdapter.FillByID(this.dsLongPlan.tblKeHoach, PlanID);
                lbldate.Text = "Ngày chỉnh sửa";

                datePlanCreated.Properties.ReadOnly = true;
                datePlanCreated.DataBindings.RemoveAt(0);
                this.datePlanCreated.DataBindings.Add(new System.Windows.Forms.Binding("EditValue", this.tblKeHoachBindingSource, "Ngày chỉnh sửa", true));
                datePlanCreated.EditValue = DateTime.Now.Date;
                this.tblLongPlanVesselTableAdapter.FillBy(this.dsLongPlan.tblLongPlanVessel, PlanID);

                this.tblCurrentOnBoardTableAdapter.Fill(this.dsAssignment.tblCurrentOnBoard);

            }


            //set default 

            // _wait.ShouldCloseNow = true;
        }
        private void loadIntervalYear()
        {
            if (đếnDateEdit.EditValue != DBNull.Value && từDateEdit.EditValue != DBNull.Value)
            {
                if ((DateTime)đếnDateEdit.EditValue > (DateTime)từDateEdit.EditValue)
                {
                    schedulerControl1.LimitInterval.Start = (DateTime)từDateEdit.EditValue;
                    schedulerControl1.LimitInterval.End = (DateTime)đếnDateEdit.EditValue;
                    schedulerControl2.LimitInterval.Start = (DateTime)từDateEdit.EditValue;
                    schedulerControl2.LimitInterval.End = (DateTime)đếnDateEdit.EditValue;
                }

            }

        }
        private void schedulerStorage1_AppointmentsChanged(object sender, PersistentObjectsEventArgs e)
        {

            updateLongPlan();

        }
        private void updateLongPlan()
        {
            if (dxValidationProvider1.Validate())
            {
                tblKeHoachBindingSource.EndEdit();
                tblKeHoachTableAdapter.Update(dsLongPlan.tblKeHoach);

                tblLongPlanVesselBindingSource.EndEdit();
                this.tblLongPlanVesselTableAdapter.Update(dsLongPlan.tblLongPlanVessel);
                dsLongPlan.AcceptChanges();
                schedulerControl1.Refresh();

            }
            else
            {
                splitContainerControl1.Collapsed = false;
            }
            //goi cap nhat parent form

            _refreshData();
        }

        private void schedulerStorage1_AppointmentsDeleted(object sender, PersistentObjectsEventArgs e)
        {
            updateLongPlan();
        }

        private void lookupVessel_EditValueChanged(object sender, EventArgs e)
        {

            if (lookupVessel.EditValue != DBNull.Value)
            {
                tblLongPlanVesselBindingSource.Filter = "nVesselId=" + (int)lookupVessel.EditValue;
                tblCurrentOnBoardBindingSource.Filter = "nVesselId=" + (int)lookupVessel.EditValue;

                schedulerControl1.ActiveView.ResourcesPerPage = 7;
                schedulerControl2.ActiveView.ResourcesPerPage = 7;
            }
            //else
            //{
            //    tblLongPlanVesselBindingSource.Filter = "";
            //    tblCurrentOnBoardBindingSource.Filter = "";
            //    schedulerControl1.ActiveView.ResourcesPerPage = 2;
            //    schedulerControl2.ActiveView.ResourcesPerPage = 2;
            //}
        }

        private void splitContainerControl1_Panel1_Leave(object sender, EventArgs e)
        {
            splitContainerControl1.Collapsed = true;
        }

        private void cmdSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            updateLongPlan();
            alertControl1.Show(this, rm.GetString("sMessageCaption", myCultureInfo), rm.GetString("sMessageSuccess", myCultureInfo));

            this.Close();
        }

        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (dsLongPlan.HasChanges())
            {
                if (XtraMessageBox.Show(rm.GetString("sHasChange", myCultureInfo), rm.GetString("sMessageCaption", myCultureInfo), MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                    updateLongPlan();

            }
            this.Close();
        }

        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (XtraMessageBox.Show(rm.GetString("sConfirm", myCultureInfo), rm.GetString("sMessageCaption", myCultureInfo), MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
            {
                tblKeHoachBindingSource.RemoveCurrent();
                tblKeHoachBindingSource.EndEdit();
                tblKeHoachTableAdapter.Update(dsLongPlan.tblKeHoach);
                alertControl1.Show(this, rm.GetString("sMessageCaption", myCultureInfo), rm.GetString("sMessageSuccess", myCultureInfo));
                this.Close();
            }

        }

        private void từDateEdit_EditValueChanged(object sender, EventArgs e)
        {
            loadIntervalYear();
        }

        private void frmLongPlanVessel_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                updateLongPlan();
            }
        }

        private void schedulerControl2_VisibleIntervalChanged(object sender, EventArgs e)
        {
            schedulerControl1.VisibleIntervalChanged -= schedulerControl1_VisibleIntervalChanged;
            schedulerControl1.ActiveView.SetVisibleIntervals(schedulerControl2.ActiveView.GetVisibleIntervals());
            schedulerControl1.VisibleIntervalChanged += schedulerControl1_VisibleIntervalChanged;
        }

        private void lookupRank_SelectedIndexChanged(object sender, EventArgs e)
        {
            lookupRank1.SelectedIndex = lookupRank.SelectedIndex;
        }

        private void lookupRank1_SelectedIndexChanged(object sender, EventArgs e)
        {
            lookupRank.SelectedIndex = lookupRank1.SelectedIndex;
        }

        private void schedulerControl1_EditAppointmentFormShowing(object sender, AppointmentFormEventArgs e)
        {
            if (isNew)
            {
                if (XtraMessageBox.Show(rm.GetString("sInsertFirst", myCultureInfo), rm.GetString("sMessageCaption", myCultureInfo), MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                {
                    if (dxValidationProvider1.Validate())
                    {
                        tblKeHoachBindingSource.EndEdit();
                        tblKeHoachTableAdapter.Update(dsLongPlan.tblKeHoach);
                        isNew = false;
                    }
                    else
                    {
                        splitContainerControl1.Collapsed = false;
                        e.Handled = true;
                        return;
                    }
                }
                else
                {
                    e.Handled = true;
                    return;
                }
            }


            Appointment apt = e.Appointment;


            DevExpress.XtraScheduler.SchedulerControl control = (DevExpress.XtraScheduler.SchedulerControl)sender;
            if (control.Storage.Appointments.IsNewAppointment(apt) == true)
            {
                apt.CustomFields["nContract"] = schedulerControl1.SelectedInterval.Duration.Days / 29;
                if (lookupVessel.EditValue != DBNull.Value)
                {
                    apt.CustomFields["VesselID"] = Convert.ToInt32(lookupVessel.EditValue);
                    apt.CustomFields["CrewID"] = "";
                    apt.CustomFields["GroupName"] = Convert.ToInt32(gridLueVessel.GetFocusedRowCellValue("nGroupId"));
                }
                else
                {
                    XtraMessageBox.Show(rm.GetString("sVesselChoice", myCultureInfo), rm.GetString("sMessageCaption", myCultureInfo), MessageBoxButtons.OK);
                    lookupVessel.Focus();
                    e.Handled = true;
                    return;
                    //apt.CustomFields["VesselID"] = 0;

                }
            }
            // Create a custom form.
            KeHoach.frmEditPlanPopup myForm = new KeHoach.frmEditPlanPopup((SchedulerControl)sender, apt, false);
            myForm.PlanID = PlanID;

            try
            {
                // Required for skins support.
                myForm.LookAndFeel.ParentLookAndFeel = schedulerControl1.LookAndFeel;
                e.DialogResult = myForm.ShowDialog();

                schedulerControl1.Refresh();
                e.Handled = true;
                this.tblLongPlanVesselTableAdapter.Update(dsLongPlan);
                dsLongPlan.AcceptChanges();

            }
            finally
            {
                myForm.Dispose();
            }
        }

        private void schedulerControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
        {
            if (e.Menu.Id == DevExpress.XtraScheduler.SchedulerMenuItemId.DefaultMenu)
            {
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.NewAllDayEvent);
                //e.Menu.RemoveMenuItem(SchedulerMenuItemId.NewRecurringAppointment);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.SwitchViewMenu);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.SwitchTimeScale);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.TimeScaleVisible);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.TimeScaleEnable);

                SchedulerMenuItem item = e.Menu.GetMenuItemById(SchedulerMenuItemId.NewAppointment);
                if (item != null) item.Caption = rm.GetString("sPlan", myCultureInfo);


                #region them mot command
                // Create a menu item for the Scheduler command.
                //ISchedulerCommandFactoryService service =
                //(ISchedulerCommandFactoryService)schedulerControl1.GetService(typeof(ISchedulerCommandFactoryService));
                //SchedulerCommand cmd = service.CreateCommand(SchedulerCommandId.SwitchToGroupByResource);
                //SchedulerMenuItemCommandWinAdapter menuItemCommandAdapter =
                //    new SchedulerMenuItemCommandWinAdapter(cmd);
                // Insert a new item into the Scheduler popup menu and handle its click event.
                //   e.Menu.Items.Add(new SchedulerMenuItem("Click me!", MyClickHandler));

                //DXMenuItem menuItem = new DXMenuItem("Lập kế hoạch", MyClickHandler) { BeginGroup = true };
                //e.Menu.Items.Add(menuItem);

                //e.Menu.MoveMenuItem(menuItem, 0); 
                #endregion
            }
        }

        private void schedulerControl1_VisibleIntervalChanged(object sender, EventArgs e)
        {
            schedulerControl2.VisibleIntervalChanged -= schedulerControl2_VisibleIntervalChanged;
            schedulerControl2.ActiveView.SetVisibleIntervals(schedulerControl1.ActiveView.GetVisibleIntervals());
            schedulerControl2.VisibleIntervalChanged += schedulerControl2_VisibleIntervalChanged;
        }

        private void lookupVessel_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {


        }



        private void schedulerControl2_AppointmentResized(object sender, AppointmentResizeEventArgs e)
        {

            updateLongPlan();
        }



        private void schedulerControl1_MouseUp(object sender, MouseEventArgs e)
        {
            schedulerControl2.MouseUp -= schedulerControl2_MouseUp;
            schedulerControl2.TimelineView.OptionsSelectionBehavior.UpdateSelectionDurationAction = UpdateSelectionDurationAction.Reset;
            schedulerControl2.ActiveView.SetSelection(schedulerControl1.SelectedInterval, schedulerControl1.SelectedResource);
            schedulerControl2.MouseUp += schedulerControl2_MouseUp;
        }

        private void schedulerControl2_MouseUp(object sender, MouseEventArgs e)
        {
            schedulerControl1.MouseUp -= schedulerControl1_MouseUp;
            schedulerControl1.TimelineView.OptionsSelectionBehavior.UpdateSelectionDurationAction = UpdateSelectionDurationAction.Reset;
            schedulerControl1.ActiveView.SetSelection(schedulerControl2.SelectedInterval, schedulerControl2.SelectedResource);
            schedulerControl1.MouseUp += schedulerControl1_MouseUp;
        }

        private void schedulerControl1_AppointmentResizing(object sender, AppointmentResizeEventArgs e)
        {

        }
        #region SCHEDULER REPORT

        public SchedulerControlPrintAdapter PrintAdapter { get; set; }


        private void SubscribePrintAdapterEvents(SchedulerPrintAdapter adapter)
        {
            if (adapter != null)
                adapter.ValidateResources += PrintAdapter_ValidateResources;
        }
        private void PrintAdapter_ValidateResources(object sender, ResourcesValidationEventArgs e)
        {
            e.Resources.Clear();
            e.Resources.AddRange(PrintResources);
        }
        ResourceBaseCollection printResources = new ResourceBaseCollection();
        public ResourceBaseCollection PrintResources { get { return printResources; } }
        private void UpdatePrintResources()
        {
            PrintResources.Clear();
            ResourceBaseCollection resources = GetPrintResources();
            PrintResources.AddRange(resources);
        }
        private ResourceBaseCollection GetPrintResources()
        {
            return GetAvailableResources();
        }
        private ResourceBaseCollection GetAvailableResources()
        {
            return PrintAdapter.SchedulerControl.Storage.Resources.Items;
        }

        private void showCurrentOnboard()
        {
            SchedulerStorage tempStorage = new SchedulerStorage();
            tempStorage = schedulerStorage1;
            for (int i = 0; i < schedulerStorage2.Appointments.Count; i++)
            {
                Appointment a = new Appointment();
                a.Subject = schedulerStorage2.Appointments[i].Subject;
                a.Start = schedulerStorage2.Appointments[i].Start;
                a.End = schedulerStorage2.Appointments[i].End;
                a.LabelId = schedulerStorage2.Appointments[i].LabelId;
                a.ResourceId = schedulerStorage2.Appointments[i].ResourceId;

                tempStorage.Appointments.Add(a);
            }

        }



        private void cmdXuat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string confirm = "";
            string caption = "";
            if (Program.language == "en")
            {
                confirm = "Do you want to add OnBoard Crew into plan?";
                caption = "Information";
            }
            else
            {
                confirm = "Bạn có muốn hiển thị thuyền viên đang trên tàu vào kế hoạch?";
                caption = "Thông báo";
            }
            if (XtraMessageBox.Show(confirm, caption, MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
            {

                showCurrentOnboard();
            }


            //schedulerControl1.Storage
            //MessageBox.Show(schedulerStorage2.Appointments[0].);
            XtraSchedulerReport report = new XtraSchedulerReport();

            report.LoadLayout(string.Format(@"{0}\Reports\daihan.repx", Application.StartupPath));
            // schedulerControl1.ActiveView.ResourcesPerPage = 100;
            if (report.Bands.GetBandByType(typeof(ReportHeaderBand)) != null)
            {


                Band band = report.Bands.GetBandByType(typeof(ReportHeaderBand));
                if (band != null) report.Bands.Remove(band);
                ReportHeaderBand newband = new ReportHeaderBand();
                report.Bands.Add(newband);

                //tieu de bao cao
                XRLabel lblCaption = new XRLabel();
                lblCaption.Text = String.Format("LONG TERM PLAN ({0} - {1})", từDateEdit.DateTime.Year, đếnDateEdit.DateTime.Year);
                lblCaption.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopCenter;
                Font f = new System.Drawing.Font(new FontFamily("Times New Roman"), 16, FontStyle.Bold);
                lblCaption.Font = f;
                lblCaption.LocationF = new PointF(0, 15);
                lblCaption.WidthF = 1070;
                //ten tau
                XRLabel lblTau = new XRLabel();
                lblTau.Text = "VESSEL NAME: " + lookupVessel.Text;
                lblTau.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                Font f1 = new System.Drawing.Font(new FontFamily("Times New Roman"), 12, FontStyle.Regular);
                lblTau.Font = f1;
                lblTau.LocationF = new PointF(0, 48f);
                lblTau.WidthF = 290f;
                //Ngay lap

                XRLabel lblNGayLap = new XRLabel();
                lblNGayLap.Text = "DATE: " + DateTime.Now.Date.ToString("dd-MM-yyyy");
                lblNGayLap.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                lblNGayLap.Font = f1;
                lblNGayLap.LocationF = new PointF(391f, 48f);
                lblNGayLap.WidthF = 290f;
                //Nguoi lap
                XRLabel lblPreparedBy = new XRLabel();
                lblPreparedBy.Text = "PLANED BY " + Program.EmployeeName;
                lblPreparedBy.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                lblPreparedBy.Font = f1;
                lblPreparedBy.LocationF = new PointF(768f, 48f);
                lblPreparedBy.WidthF = 290f;

                newband.Controls.Add(lblCaption);
                newband.Controls.Add(lblTau);
                newband.Controls.Add(lblNGayLap);
                newband.Controls.Add(lblPreparedBy);
            }

            PrintAdapter = new SchedulerControlPrintAdapter(schedulerControl1);
            SchedulerStoragePrintAdapter tad = new SchedulerStoragePrintAdapter(schedulerStorage1);

            report.SchedulerAdapter = tad;


            UpdatePrintResources();
            SubscribePrintAdapterEvents(report.SchedulerAdapter);
            tad.TimeInterval.Start = từDateEdit.DateTime;
            tad.TimeInterval.End = đếnDateEdit.DateTime;
            report.ShowPreviewDialog();

            schedulerStorage1.RefreshData();


        }
        #endregion

        private void veselGroup_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {

            if (e.Button.IsLeft)
            {

                lookupVessel.EditValue = DBNull.Value;
                veselGroup.EditValue = DBNull.Value;

                tblCurrentOnBoardBindingSource.Filter = "";
                tblLongPlanVesselBindingSource.Filter = "";
                schedulerControl1.ActiveView.ResourcesPerPage = 2;
                schedulerControl2.ActiveView.ResourcesPerPage = 2;

            }
        }

        private void veselGroup_EditValueChanged(object sender, EventArgs e)
        {
            if (veselGroup.EditValue != DBNull.Value)
            {
                tblVesselBindingSource.Filter = "nGroupId=" + Convert.ToInt32(veselGroup.EditValue);
                tblCurrentOnBoardBindingSource.Filter = "nGroupId=" + Convert.ToInt32(veselGroup.EditValue);
                tblLongPlanVesselBindingSource.Filter = "GroupName=" + Convert.ToInt32(veselGroup.EditValue);
            }


        }

        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

        }

    }
}